package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/** 读取文本数据 */
public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        File file1=new File("fos1.txt");
        FileInputStream fis1=new FileInputStream(file1);
        byte[] data1=new byte[(int)file1.length()];
        fis1.read(data1);
        String line1=new String(data1, StandardCharsets.UTF_8);
        System.out.println(line1);
        fis1.close();


        File file2=new File("fos2.txt");
        FileInputStream fis2=new FileInputStream(file2);
        byte[] data2=new byte[(int)file2.length()];
        fis2.read(data2);
        String line2=new String(data2,StandardCharsets.UTF_8);
        System.out.println(line2);
        fis2.close();
    }
}
